<?php
class dbLayerSingleton extends dbLayer {
	
	/**
	 * Singleton class 
	 */	
	private static $instance;
	
	/**
	 * Gives an instance of dbLayer
	 * @param	string		$driver		
	 * @param	string		$host		
	 * @param	string		$database
	 * @param	string		$user
	 * @param	string		$password
	 * @param	boolean		$persistent
	 * @return	instance du driver	
	 */
	public static function getInstance($driver, $host, $database, $user='', $password='', $persistent=false) {
		if (!isset(self::$instance)) {
			self::$instance = dbLayerSingleton::init($driver, $host, $database, $user, $password, $persistent);
		}
		return self::$instance;
	}
	
	/**
	 * Returns the last inserted primary key in the database.
	 * (Only compatible with MySQL driver at the moment. Feel free to contribute !)
	 * FIXME All drivers support is needed. But shouldn't be supported inside of Clearbricks/Dblayer ?
	 */
	public static function insert_id() {
		return mysql_insert_id();
	}
	
	public function __destruct()
	{
		$this->close();
	}
	
}
?>
